package com.huaxin.hxcloud.find;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.huaxin.common.BaseActivity;
import com.huaxin.common.Entity.HxCommentStateBean;
import com.huaxin.common.Global;
import com.huaxin.hxcloud.R;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by songxf on 2017/8/8.
 */

public class HxCommentStateActivity extends BaseActivity {
    @BindView(R.id.more)
    ImageView    mMore;
    @BindView(R.id.tv_unread)
    TextView     mTvUnread;
    @BindView(R.id.toolbar)
    Toolbar      mToolbar;
    @BindView(R.id.recyclerview)
    RecyclerView mRecyclerview;
    private List<HxCommentStateBean> mCommentSateBeanList;
    private HxCommentStateAdapter    mAdapter;
    private static final String TAG = "HxCommentStateActivity";

    @Override
    protected int getContentViewId() {
        return R.layout.activity_comment_state;
    }

    @Override
    public int getLoadFrameId() {
        return R.id.content;
    }


    @Override
    public void initView() {
        setSupportActionBar(mToolbar);
        mToolbar.setTitle("可见");
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });


        updateLoadStatus(LOAD_SUCCESS);
        mCommentSateBeanList = new ArrayList<>();
        mRecyclerview.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerview.setHasFixedSize(true);
        mAdapter = new HxCommentStateAdapter(this, mCommentSateBeanList);
        mRecyclerview.setAdapter(mAdapter);

    }

    @Override
    public void initData() {
        mCommentSateBeanList.add(new HxCommentStateBean("行业", "上传平台共同探讨", false, 4));
        mCommentSateBeanList.add(new HxCommentStateBean("私密", "仅自己可见", false, 3));
        mCommentSateBeanList.add(new HxCommentStateBean("仅好友可见", "仅已添加的好友可见", false, 2));
        if (Global.user.getOrgCode() != null) {
            mCommentSateBeanList.add(new HxCommentStateBean("仅企业可见", "仅相关企业内部人员可见", false, 1));

        }
        mAdapter.notifyDataSetChanged();
        mAdapter.setOnItemClickListener(new HxCommentStateAdapter.OnViewItemClickListener() {
            @Override
            public void onItemClick(int position) {
                mCommentSateBeanList.get(position).setCheck(true);
                EventBus.getDefault().post(new HxCommentStateEventBus(mCommentSateBeanList.get(position), position));
                finish();
            }
        });
    }
}
